package mid

import "math"

func MaxScore(nums []int, x int) int {
	res := int(nums[0])
	dp := [2]int{math.MinInt32, math.MinInt32}
	dp[nums[0]%2] = int(nums[0])
	for i := 1; i < len(nums); i++ {
		parity := nums[i] % 2
		cur := max(dp[parity]+int(nums[i]), dp[1-parity]-int(x)+int(nums[i]))
		res = max(res, cur)
		dp[parity] = max(dp[parity], cur)
	}
	return res
}
